package my.algorithms.sort;

/**
 * Created by IntelliJ IDEA.
 * User: jtruelove
 * Date: 3/12/11
 * Time: 9:51 AM
 * To change this template use File | Settings | File Templates.
 */
public class BubbleSort
{
    /**
     *
     *
     * @param array
     */
    public static void sort(int [] array)
    {

        for(int i = 1; i < array.length; i++)
        {
            for (int j = 0; j < array.length - i; j++)
            {
                if (array[j] > array[j+1])
                {
                    int tmp = array[j];
                    array[j] = array[j+1];
                    array[j+1] = tmp;
                }
            }
        }
    }

    public static void printArray(int [] array)
    {
        for (int num : array)
        {
            System.out.print(num + "  ");
        }
        System.out.println();
    }

    public static void main (String [] args)
    {
        int [] array = new int [] {2,5,1,7,6,8,0};
        sort(array);
        printArray (array);
    }
}
